package com.byq.mcpanus.controller;

import com.byq.mcpanus.model.McpDomain;
import com.byq.mcpanus.repository.McpDomainRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.security.access.prepost.PreAuthorize;
import java.util.List;

@RestController
@RequestMapping("account")
public class AccountDomainController {
    @Autowired
    private McpDomainRepository mcpDomainRepository;

    @PreAuthorize("hasRole('CUSTOMER')")
    @GetMapping("/mydomains")
    public ResponseEntity<List<McpDomain>> myDomains() {
        List<McpDomain> domains = mcpDomainRepository.findAll();
        return ResponseEntity.ok(domains);
    }
} 